package servlet;

import service.UserService;
import service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/removeUserServletServlet")
public class RemoveUserServletServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //我要删除  就在list的删除链接后面拼接上id参数,我点击删除 我就把参数Id带了过来  我就可以直接的通过id这个参数删除指定的user
        String id = request.getParameter("id");
        System.out.println(id );
        UserService service = new UserServiceImpl() ;
        service.removeUser(id) ;
        //我需要跳转页面 用到重定向
        response.sendRedirect("/day20/findPageUserServlet");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doPost(request,response);
    }
}
